// copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
// see COPYRIGHT for reuse legalities
//

#import "WW3DWell.h"
#import "WW3DWellIBInspector.h"
#import "aspectRatios.h"

@implementation WW3DWellIBInspector

- init {
    char buf[MAXPATHLEN + 1];
    id bundle;
    
    [super init];
    
    bundle = [NXBundle bundleForClass:[WW3DWell class]];
    [bundle getPath:buf forResource:"WW3DWellIBInspector" ofType:"nib"];
    [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
    [self revert:self];

    return self;
}

- revert:sender 
{ 
  // kinda gross...
  [object setCustomAspectRatioText:customAspectRatioText];

  [reuseImageViewSwitch setIntValue:[object reuseImageView]];
  [ignoreColorsSwitch setIntValue:[object ignoreColors]];
  [ignoreShadersSwitch setIntValue:[object ignoreShaders]];
  [firmTransformsSwitch setIntValue:[object firmTransforms]];
  [lowRezTesselationText setFloatValue:[object lowRezTesselation]];
  [tesselationText setFloatValue:[object tesselation]];
  [projectionTypeMatrix selectCellWithTag:[object projectionType]];
  [selectedColorWell setColor:[object selectedColor]];
  [unselectedColorWell setColor:[object unselectedColor]];
  [shadingRateText setFloatValue:[object  shadingRate]];
  [shadingRateSlider setFloatValue:[object shadingRate]];
  [aspectRatioMatrix selectCellWithTag:[object aspectRatioType]];
  [customAspectRatioText setEnabled:([object aspectRatioType] == WW_ASPECT_CUSTOM)];
  [customAspectRatioText setFloatValue:[object aspectRatio]];
  [fovText setFloatValue:[object fov]];
  [fovSlider setFloatValue:[object fov]];
  [initialGeometryText setStringValue:""];
  [initialImageText setStringValue:""];

  return self;
}

#define OK [self revert:nil]; return [super ok:sender];

- setReuseImageView_:sender  { [object takeReuseImageView:sender]; OK; }
- setLowRezTesselation_:sender  { [object takeLowRezTesselation:sender]; OK; }
- setTesselation_:sender  { [object takeTesselation:sender]; OK; }
- setIgnoreColors_:sender  { [object takeIgnoreColors:sender]; OK; }
- setIgnoreShaders_:sender  { [object takeIgnoreShaders:sender]; OK; }
- setFirmTransforms_:sender  { [object takeFirmTransforms:sender]; OK; }
- setAspectRatioFromMatrix_:sender  { [object takeAspectRatioFromMatrix:sender]; OK; }
- setAspectRatio_:sender   { [object takeAspectRatio:sender]; OK; }
- setFOV_:sender  { [object takeFOV:sender]; OK; }
- setShadingRate_:sender  { [object takeShadingRate:sender]; OK; }
- setSelectedColor_:sender  { [object takeSelectedColor:sender]; OK; }
- setUnselectedColor_:sender  { [object takeUnselectedColor:sender]; OK; }
- setProjectionTypeFromMatrix_:sender  { [object takeProjectionTypeFromMatrix:sender]; OK; }
- setInitialGeometry_:sender  { [object takeInitialGeometry:sender]; OK; }
- setInitialImage_:sender  { [object takeInitialImage:sender]; OK; }

- (BOOL)wantsButtons	{ return NO; }

@end
